home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / XDATE / XDATE.PAS < prev   
Pascal/Delphi Source File  |  1992-02-05  |  3KB  |  85 lines

  1. {**********************************************************************}
  2. {                                                                      }
  3. { Author:        Michael L. Peters                                     }
  4. { Date:          February 3, 1992                                      }
  5. { Purpose:       Turbo Vision Object to display current date on        }
  6. {                DeskTop in the format: DayOfWeek Day-Month-Year       }            
  7. {                                       eg. Mon 3-Feb-1992             }
  8. {                                                                      }
  9. {                                                                      }
  10. { Copyright (c): Availible to all in the public domain.                }
  11. { Coments:       Use TestPlat.PAS and DT_Test.PAS to demonstrate this  }
  12. {                unit.  Please leave comments and messages on          }
  13. {                 CompuServe  ID  # 70421,727.                         }            
  14. {                                                                      }
  15. {**********************************************************************}
  16. {2-03-92  11:00pm}
  17.  
  18. UNIT XDate;
  19.  
  20. interface
  21.  
  22. uses DOS, OBJECTS, VIEWS, APP;
  23.  
  24. type
  25.     PDateView =^TDateView;
  26.     TDateView = object(TView)
  27.       DateStr: string[15];
  28.       Year, Month, Day, DayOfWeek: word;
  29.       Old_day: word;
  30.       constructor Init( var Bounds: TRect);
  31.       procedure Draw; virtual;
  32.       function FSDate: String;
  33.       procedure Update; Virtual;
  34.     end;
  35.  
  36. implementation
  37.  
  38. uses Drivers;
  39.  
  40. {----------- Date Window Object ----------}
  41.  
  42. constructor TDateView.Init( var Bounds: TRect);
  43. begin
  44.      TView.Init(bounds);
  45. end;
  46.  
  47. procedure TDateView.Draw;
  48. var
  49.   B: TDrawBuffer;
  50.   C: Byte;
  51.   X: Word;
  52. begin
  53.      getdate(Year, Month, Day, DayOfWeek);
  54.      Old_day := Day;
  55.      DateStr := FSDate;
  56.      C:= GetColor(2);
  57.      MoveChar(B, ' ',C, Size.X);
  58.      MoveStr(B, DateStr, C);
  59.      Writeline(0, 0, Size.X, 1, B);
  60. end;
  61.  
  62. procedure TDateView.Update;
  63. var
  64.    Dum, New_Day : word;
  65. begin
  66.      getdate(Dum, Dum, New_Day, Dum);
  67.      if New_Day <> Old_Day then
  68.         drawview;
  69. end;
  70.  
  71. function TDateView.FSDate: String;
  72. const Days : ARRAY[ 0..6 ] OF String[3] = ('Sun', 'Mon', 'Tue','Wed', 'Thu',
  73.                         'Fri', 'Sat' );
  74.       Months : ARRAY[ 1 .. 12 ] OF String[3] = ('Jan', 'Feb','Mar', 'Apr',
  75.                         'May', 'Jun', 'Jul', 'Aug', 'Sep','Oct', 'Nov','Dec');
  76. var
  77.   DayString, YearString: String[4];
  78. Begin
  79.      Str(Day, DayString);
  80.      Str(Year, YearString);
  81.      FSDate := days[DayOfWeek] + ' ' + DayString + '-' + months[Month] +'-' +
  82.                YearString;
  83. end;
  84.  
  85. end.